package com.ych.bean;

import lombok.Data;

import java.io.Serializable;

/**
 * @BelongsProject: ape-frame
 * @BelongsPackage: com.ych.bean
 * @Author: ych
 * @CreateTime: 2024-11-18  11:03
 * @Description: TODO
 * @Version: 1.0
 */

@Data
public class Result<T> implements Serializable {
    private Boolean success;

    private Integer code;

    private String message;

    private T data;

    private Result() {
    }

    public static Result ok() {
        return ok(null);
    }

    public static <T> Result ok(T data) {
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMessage(ResultEnum.SUCCESS.getMessage());
        result.setData(data);
        return result;
    }

    public static Result other(Integer resultCode, String resultMessage) {
        return other(resultCode, resultMessage, null);
    }

    public static <T> Result other(Integer resultCode, String resultMessage, T data) {
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(resultCode);
        result.setMessage(resultMessage);
        result.setData(data);
        return result;
    }


}
